//package cn.mystylefree.my_persistence_demo.dao;
//
//import cn.mystylefree.io.Resources;
//import cn.mystylefree.my_persistence_demo.domain.User1;
//import cn.mystylefree.sqlSession.SqlSession;
//import cn.mystylefree.sqlSession.SqlSessionFactory;
//import cn.mystylefree.sqlSession.SqlSessionFactoryBuilder;
//import org.dom4j.DocumentException;
//
//import java.beans.PropertyVetoException;
//import java.io.InputStream;
//import java.lang.reflect.Proxy;
//import java.util.List;
//import java.util.function.Function;
//import java.util.stream.Collectors;
//
///**
// * @program my-project-model
// * @description:
// * @author: lee
// * @create: 2022/06/17 16:32
// */
//public class UserDao implements IUserDao {
//
//    @Override
//    public List<User1> findAll() throws PropertyVetoException, DocumentException {
////        InputStream resourceAsStream = Resources.getResourceAsStream("sqlMapConfig.xml");
////        SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
////
////        SqlSession sqlSession = sessionFactory.openSession();
//        SqlSession sqlSession = getSqlSession();
//        List<Object> list = sqlSession.selectList("user.selectList");
//        List<User1> collect = list.stream()
//                .filter(e -> e instanceof User1)
//                .map(e -> (User1) (e))
//                .collect(Collectors.toList());
//        return collect;
//    }
//
//    /*优化
//     * 1.代码重复
//     * 2.硬编码问题*/
//    //解决方法，把实现类干掉？？？
//    //解决思路
//    //不要dao的实现类
//
//    //使用代理类生成Dao层接口的代理实现类（底层的调用都交给代理实现类实现）
//
//
//    private SqlSession getSqlSession() throws PropertyVetoException, DocumentException {
//        InputStream resourceAsStream = Resources.getResourceAsStream("sqlMapConfig.xml");
//        SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
//        SqlSession sqlSession = sessionFactory.openSession();
//        return sqlSession;
//    }
//
//    @Override
//    public User1 findByCondition(User1 user) throws PropertyVetoException, DocumentException {
////        InputStream resourceAsStream = Resources.getResourceAsStream("sqlMapConfig.xml");
////        SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);
////
////        SqlSession sqlSession = sessionFactory.openSession();
//        SqlSession sqlSession = getSqlSession();
//        Object o = sqlSession.selectOne("user.selectOne", user);
//        return o instanceof User1 ? (User1) o : null;
//    }
//
//
//}
